import { BroadCastCall } from "../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../Framework/MQ/MessageBlock";
import { SBag } from "../../../../Message/Game/SBag";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../mvc/ServerCommand";
import { Cache } from "../../cache/Cache";
import { ItemData } from "../../resource/info/ItemData";
import { EPlayerItemPosType } from "../../../../Message/Public/EPlayerItemPosType";
import { PetEquipCache } from "../../cache/PetEquipCache";
import { SPlayerItem } from "../../../../Message/Public/SPlayerItem";
import { ItemsUtil } from "../../view/shortcuts/item/ItemsUtil";
//class PackInfoCommand
    
    export  class PackInfoCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            loc1 = arg1.messageBase as SBag;
            var loc5=loc1.posType;
            switch (loc5) 
            {
                case 0:
                {
                    _cache.pack.backPackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.BackpackDataChange, null);
                    break;
                }
                case 1:
                {
                    _cache.pack.wareHousePackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.WareHouseDataChange, null);
                    break;
                }
                case 3:
                {
                    _cache.pack.rolePackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.RolepackDataChange, null);
                    if (Cache.instance.pack.mountsPackCache.equipEdMount && !(Cache.instance.pack.mountsPackCache.equipEdMount == ItemData.nullItemData) && Cache.instance.pack.mountsPackCache.equipEdMount.itemExInfo.mount_equipped_state == 0) 
                    {
                        Cache.instance.pack.mountsPackCache.callEdMount = Cache.instance.pack.mountsPackCache.equipEdMount;
                    }
                    break;
                }
                case 5:
                {
                    _cache.pack.backPackExtendPackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.BackPackExtendDataChange, null);
                    break;
                }
                case 6:
                {
                    _cache.pack.wareHouseExtendPackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.WareHouseExtendDataChange, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeStall:
                {
                    _cache.pack.stallPackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.StallItemsUpdate, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeRunBusiness:
                {
                    _cache.pack.runBusinessPackCache.sbag = loc1;
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeTreasure:
                {
                    _cache.pack.treasurePackCache.sbag = loc1;
                    _cache.pack.treasurePackCopy.sbag = loc1;
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeFish:
                {
                    _cache.pack.fishPackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.FishItemsUpdate, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeCopyBox:
                {
                    _cache.pack.copyBox.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.CopyBoxItemUpdate, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeDelegate:
                {
                    _cache.pack.delegate.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.DelegateWarehouseItemsUpdate, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypePetExplore:
                {
                    _cache.pack.petExplorePackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.PetExplorePackCommand, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeWardrobe:
                {
                    _cache.pack.wardrobePackCache.sbag = loc1;
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeRune:
                {
                    _cache.pack.runePackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.RunePackDataChange, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypePetLifeStypePut:
                {
                    _cache.pack.petMingPackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.PetMingPackCommand, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypePetLifeStypeHunt:
                {
                    _cache.pack.petMingJuPackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.PetMingJuPackCommand, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeStoneBag:
                {
                    _cache.pack.stonePackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.StonepackDataChange, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeAmuletBag:
                {
                    _cache.pack.magicWeaponPackCache.sbag = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.MagicWeaponPackDataChange, null);
                    break;
                }
                default:
                {
                    loc2 = _cache.pack.getPackChacheByPosType(loc1.posType);
                    if (loc2) 
                    {
                        loc2.sbag = loc1;
                    }
                    if (typeof loc2 === "petequipcache") 
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.PetEquipItemInfoChange, null);
                    }
                    if (loc1.posType > EPlayerItemPosType._EPlayerItemPosTypePetEquipBase) 
                    {
                        if ((loc3 = new ItemData(loc1.playerItems[0] as SPlayerItem)) && ItemsUtil.isPetLifeStyle(loc3)) 
                        {
                            loc4 = loc1.posType - EPlayerItemPosType._EPlayerItemPosTypePetEquipBase;
                            _cache.petMing.mingCapacituDict[loc4] = loc1.capacity;
                        }
                        NetDispatcher.dispatchCmd(ServerCommand.PetMingCapacityCommand, _cache.petMing.mingCapacituDict);
                    }
                    break;
                }
            }
            return;
        }
    }
